<%@page import="org.eclipse.jdt.internal.compiler.ast.ForeachStatement"%>
<%@ page import="java.io.*,java.util.*, java.sql.*, org.lionsteins.eddie.server.*,org.lionsteins.eddie.domain.Alert, org.hibernate.Session, org.hibernate.*" %>

<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Historical Alerts</title>

<link rel="stylesheet" type="text/css" href="css/mystyles.css" media="screen" />


</head>
<body>

<%
StringBuffer sb = new StringBuffer();
try {
	Session hSession = SessionFactoryUtil.getSessionFactory().openSession();

	hSession.beginTransaction();

Query query = hSession.createQuery("from Alert ");
		
ArrayList temp = (ArrayList) query.list();



   java.util.Date utilDate = new java.util.Date(System.currentTimeMillis());
   
   java.sql.Date date=new java.sql.Date(utilDate.getTime());
   Timestamp timestamp = new Timestamp(date.getTime());
   for (int i=0; i< temp.size(); i++) {
	   
	   sb.append("<tr>");
	   sb.append("<td>");
	   sb.append("<br>");
	   sb.append(" identifier:");
		sb.append("<a href='alertlookup2.jsp?id=");
		Alert obj = (Alert)temp.get(i);
	   String id = obj.getId().toString();
		sb.append(id);
		sb.append("'>");
		sb.append(id);
		sb.append("</a>");
	   
	   sb.append(" sender: ");
	   sb.append(obj.getSender());
	   
	   sb.append(" sent: ");
	   sb.append(obj.getDate());
	   
	   sb.append(" location: ");
	   sb.append(obj.getLocation());
	   
	   sb.append("</td>");
	   sb.append("</tr>");
   }
   
   
		
}catch(Exception e){
   //Handle errors for Class.forName
   e.printStackTrace();
}finally{
}//end try

	out.println("Results: ");
	out.println("<table align=\"center\"  bgcolor=\"white\" >");
	out.println(sb.toString());
		
	out.println("</table >");
%>
</body>
</html>
